#ifndef THREAD_CONDITION_H
#define THREAD_CONDITION_H

// Monitor to provide mutual exclusion.
class Thread_Condition
{
public:
	Thread_Condition(Thread_Mutex *m_)
	{
		Mutex_ = m_;
		CondMutex_ = new Thread_Mutex();
	}
	
	virtual ~Thread_Condition() 
	{
		delete CondMutex_;
	}

	void wait(int timeout)
	{
		Mutex_->signal();
		CondMutex_->wait(timeout);
		Mutex_->wait();
	}

	void wait(void)
	{
		Mutex_->signal();
		CondMutex_->wait();
		Mutex_->wait();
	}

	void notify(void)
	{
		CondMutex_->signal();
	}

private:
	Thread_Mutex *Mutex_;
	Thread_Mutex *CondMutex_;
};

#endif